package com.stox.ui.javafx.charting.event.listener;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;

import org.springframework.stereotype.Component;

import com.stox.ui.javafx.charting.model.enumeration.ChartType;
import com.stox.ui.javafx.charting.view.ChartingView;

@Component
public class ChartTypeChangeListener implements ChangeListener<ChartType> {

	@Override
	public void changed(ObservableValue<? extends ChartType> arg0, ChartType arg1, ChartType chartType) {
		ChartingView chartingView = ChartingView.getSelectedChartingView();
		if(chartingView != null) {
			chartingView.getPrimaryChart().getFrontPlot().setChartType(chartType);
		}
		chartingView.update();
	}
	
}
